package com.isoft.demo.controller;/*
 *@ClassName: FindTransferSysController
 *@Date: 2021/6/28
 *@Author:刘逸飞
 */


import com.isoft.demo.common.ResponseData;
import com.isoft.demo.entity.Transport;
import com.isoft.demo.service.FindTransferSysService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@RestController
@CrossOrigin
public class FindTransferSysController {

    @Resource
    private FindTransferSysService service;

    //默认显示全部信息
    @GetMapping("/sys/findtrans")
    public ResponseData findTransSys(){
        ResponseData rs=service.findTranSys();
        return rs;
    }

    //按tid查询
    @GetMapping("/sys/findtrans/ById")
    public ResponseData findById(int tid){
        ResponseData rs=service.findById(tid);
        return rs;
    }

    //按时间范围查询
    @GetMapping("/sys/findtrans/ByDate")
    public ResponseData findByDate(String sdate,String edate){
//        sdate="2021-7-1";
//        edate="2021-8-2";
        ResponseData rs=service.findByDate(sdate,edate);
        return rs;
    }

    //按tid,时间范围多条件查询
    @GetMapping("/sys/findtrans/By")
    public ResponseData findBy(int tid,String sdate,String edate){
        ResponseData rs=service.findBy(tid,sdate,edate);
        return rs;
    }

    @GetMapping("/addTransport")
    public ResponseData addTransport(Transport transport){
//        获取当前系统时间
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        transport.setTdate(format.format(date));
        ResponseData rs = service.addTransport(transport);
        return rs;
    }
}
